<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<%@ page import="java.util.List"%>
<%@ page isELIgnored="false" %> <%--isELIgnored=true禁用EL表达式--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>用户中心</title>
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/reset.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/main.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.min-2.1.1.js"></script>
</head>
<body>
	<div class="header_con">
		<div class="header">
			<div class="fr">
				<div class="login_btn fl">
				    欢迎您：<em>${user.uName}</em>
                    <span>|</span>
					<a href="loginPage">注销</a>
					<span>|</span>
					<a href="register">注册</a>
				</div>
				<div class="user_link fl">
					<span>|</span>
					<a href="centerPage?id=${user.id}">用户中心</a>
					<span>|</span>
					<a href="/shop/cartPage?uId=${user.id}">我的购物车</a>
					<span>|</span>
					<a href="centerOrderPage?id=${user.id}">我的订单</a>
				</div>
			</div>
		</div>		
	</div>

	<div class="search_bar clearfix">
		<a href="/shop/list?id=${user.id}" class="logo fl"><img src="<%=request.getContextPath() %>/images/logo.png" style="width: 125px;height: 80px;"></a>
		<div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;用户中心</div>
		<div class="search_con fr">
			<input type="text" class="input_text fl" name="" placeholder="搜索商品">
			<input type="button" class="input_btn fr" name="" value="搜索">
		</div>		
	</div>

	<div class="main_con clearfix">
		<div class="left_menu_con clearfix">
			<h3>用户中心</h3>
			<ul>
				<li><a href="centerPage?id=${user.id}">· 个人信息</a></li>
				<li><a href="centerOrderPage?id=${user.id}" class="active">· 全部订单</a></li>
			</ul>
		</div>
		<div class="right_content clearfix">
				<h3 class="common_title2">全部订单</h3>
				<c:forEach items="${list}" var="order">
                    <ul class="order_list_th w978 clearfix">
                        <li class="col01">${order.createTime}</li>
                        <li class="col02">订单号：${order.orderNo}</li>
                        <li class="col02 stress">
                            <c:if test="${order.orderStatus}==1">待付款</c:if>
                            <c:if test="${order.orderStatus}==2">待发货</c:if>
                            <c:if test="${order.orderStatus}==3">已发货</c:if>
                            <c:if test="${order.orderStatus}==4">已签收</c:if>
                            <c:if test="${order.orderStatus}==5">退款中</c:if>
                            <c:if test="${order.orderStatus}==6">已退款</c:if>
                            <c:if test="${order.orderStatus}==7">交易关闭</c:if>
                        </li>
                    </ul>

                    <table class="order_list_table w980">
                        <tbody>
                            <tr>
                                <td width="55%">
                                    <ul class="order_goods_list clearfix">
                                        <li class="col01"><img src="http://localhost:8887/${order.imgUrl}"></li>
                                        <li class="col02">${order.gName}</li>
                                        <li class="col03"><em>${order.gPrice}</em></li>
                                        <li class="col04">${order.buyCount}件</li>
                                    </ul>
                                </td>
                                <td width="15%">${order.orderMoney}元</td>
                                <td width="15%">
                                    <c:if test="${order.orderStatus==1}">待付款</c:if>
                                    <c:if test="${order.orderStatus==2}">待发货</c:if>
                                    <c:if test="${order.orderStatus==3}">已发货</c:if>
                                    <c:if test="${order.orderStatus==4}">已签收</c:if>
                                    <c:if test="${order.orderStatus==5}">退款中</c:if>
                                    <c:if test="${order.orderStatus==6}">已退款</c:if>
                                    <c:if test="${order.orderStatus==7}">交易关闭</c:if>
                                </td>
                                <c:if test="${order.orderStatus==1}"><td width="15%"><a href="#" class="oper_btn">去付款</a></td></c:if>
                                <c:if test="${order.orderStatus==2 || order.orderStatus==3 || order.orderStatus==4}"><td width="15%"><a href="#" class="oper_btn" onclick="requestRefund(${order.orderStatus} , '${order.orderNo}')">申请退款</a></td></c:if>
                                <c:if test="${order.orderStatus==5}"><td width="15%"><a href="#" class="oper_btn" onclick="overRefund(${order.preStatus}, '${order.orderNo}')">取消退款</a></td></c:if>
                                <c:if test="${order.orderStatus==3}"><td width="15%"><a href="#" class="oper_btn" onclick="sign(${order.orderStatus}, '${order.orderNo}')">签收</a></td></c:if>
                            </tr>
                        </tbody>
                    </table>
				</c:forEach>
				


				<div class="pagenation">
					<a href="#"><上一页</a>
					<a href="#" class="active">1</a>
					<a href="#">2</a>
					<a href="#">3</a>
					<a href="#">4</a>
					<a href="#">5</a>
					<a href="#">下一页></a>
				</div>
		</div>
	</div>

	<div class="footer">
		<div class="foot_link">
			<a href="#">张旭光太胖</a>
			<span>|</span>
			<a href="#">张旭光太丑</a>
			<span>|</span>
			<a href="#">张旭光太虚</a>
			<span>|</span>
			<a href="#">健脑补肾丸</a>
		</div>
		<p> 北京旭光补肾技术有限公司 </p>
		<p>电话：541885418828    京ICP备*******8号</p>
	</div>
	<script>
	    function requestRefund(orderStatus, orderNo){
	        var params= "preStatus="+orderStatus+"&orderStatus=5&orderNo="+orderNo;
	        console.info(params);
	        $.ajax({
	            url:"/order/updateOrderStatus",
	            data:params,
	            type:"post",
	            success:function(str){
	                if(str =="1"){
	                    alert("申请退款成功");
	                    parent.location.reload();
	                }else{
	                    alert("申请退款失败,请联系客服处理");
	                }
	            }
	        })
	    }

	    function overRefund(preStatus, orderNo){
	        var params = "orderStatus="+preStatus+"&preStatus=2&orderNo="+orderNo;
	         $.ajax({
                url:"/order/updateOrderStatus",
                data:params,
                type:"post",
                success:function(str){
                    if(str =="1"){
                        alert("取消退款成功");
                        parent.location.reload();
                    }else{
                        alert("取消退款失败,请联系客服处理");
                    }
                }
            })
	    }

	    function sign(orderStatus, orderNo){
	        var params="preStatus="+orderStatus+"&orderStatus=4&orderNo="+orderNo;
	        $.ajax({
	            url:"/order/sign",
                data:params,
                type:"post",
                success:function(str){
                    if(str =="1"){
                        alert("签收成功");
                        parent.location.reload();
                    }else{
                        alert("签收失败,请联系客服处理");
                    }
                }
	        })
	    }
	</script>
</body>
</html>